#ifndef _GRAPHICSDEVICE
#define _GRAPHICSDEVICE
#include "SDL2/SDL.h"
#include <algorithm>
#include<iostream>

using namespace std;


typedef unsigned char BYTE;
typedef unsigned int COLORREF;
typedef unsigned int DWORD;
typedef unsigned char byte;
typedef unsigned short WORD;
typedef int LONG;

#define RGB(r, g, b) ((COLORREF)(((BYTE)(r) | ((WORD)((BYTE)(g)) << 8)) | (((DWORD)(BYTE)(b)) << 16)))
#define GetBValue(rgb) (BYTE(rgb))
#define GetGValue(rgb) (BYTE(((WORD)(rgb)) >> 8))
#define GetRValue(rgb) (BYTE((rgb) >> 16))
#define BGR(color) ((((color)&0xFF) << 16) | ((color)&0xFF00FF00) | (((color)&0xFF0000) >> 16))
#ifndef _max
#define _max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef _min
#define _min(a, b) (((a) < (b)) ? (a) : (b))
#endif

class GraphicsDevice
{
public:
	size_t width, height;//记录屏幕的宽高
	SDL_Window *win;
	SDL_Renderer *ren;
	SDL_Surface *bmp;
	SDL_Texture *tex;
	GraphicsDevice(int width, int height);
	void SetPixel(int x, int y, COLORREF c);
	void SetPixel_Back(int x, int y, COLORREF c);//将像素设置到缓冲区中
	void flush();//将后缓冲区的数据复制到前缓冲区
	void clear_color_bcak(COLORREF c);
	~GraphicsDevice();
	DWORD* backBuffer;//后缓冲区
	DWORD* g_pBuf;//显存指针
};
#endif

